#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

void ReadFile(){
    string outFileName = "out.out";
	string inFileName = "in.in";
    ofstream outfs(outFileName.c_str(),ios::out);
    ifstream infs(inFileName.c_str(),ios::in);
    string line;
    while(getline(infs,line))
    {
        istringstream stream(line);
		//5 = 2 + 3 + 4
		
		int sum ;
		char temp;
		stream>>sum; 
		outfs<<"var sum"<<sum<<"=0;"<<endl;
		while(stream>>temp){
			int pt;
			if(temp == '=' || temp == '+'){
				stream>>pt;
outfs<<"if($(\'input[id=cal"<<pt<<"]\').val().replace(/,/g,\'\') != \"\"){		sum"<<sum<<"+=parseInt($(\'input[id=cal"<<pt<<"]\').val().replace(/,/g,\'\'));	}"<<endl;
			}else if(temp == '-'){
				stream>>pt;
outfs<<"if($(\'input[id=cal"<<pt<<"]\').val().replace(/,/g,\'\') != \"\"){		sum"<<sum<<"-=parseInt($(\'input[id=cal"<<pt<<"]\').val().replace(/,/g,\'\'));	}"<<endl;
			}else break;
			
		}
		
		outfs<<"if(!isNaN(sum"<<sum<<")){  var te = parseFloat(sum"<<sum<<");	$(\'input[id=cal"<<sum<<"]\').val(comdify(te)); }"<<endl;
	}
		

	infs.close();
    outfs.close();
}

int main()
{
    ReadFile();
    return 0;
}
